function popup(target) {
	$('fade').className = 'block';
	$('popup-'+target).style.display = 'block';
	if($('popup-'+target).getElement('input')) {
		$('popup-'+target).getElement('input').focus();
	}
}

function close_popup() {
	if($('fade').className == 'block')
		$('fade').className = 'invisible';
	if(document.getElement('div.popup')) {
		var popper = document.getElement('div.popup');
		if(popper.style.display == 'block') {
			popper.style.display = 'none';
		}
	}
}

function forgotPass() {
	$('user-login-form').className = 'invisible';
	$('forgot-pass-form').className = 'visible';
}

function cancelForgotPass() {
	$('user-login-form').className = 'visible';
	$('forgot-pass-form').className = 'invisible';
}

function editInput(target,caller) {
	if($(target)) {
		var temp = $(target).innerHTML;
		$(target).destroy();
		var input = new Element('input', {
			'type': 'text',
		    'value': temp
		});
		input.inject($(caller),'before');
		input.focus();
		input.select();
		$(caller).href = '#';
		$(caller).innerHTML = 'done';
	}
}

window.addEvent('domready', function() {
	if($('parser-update')) { 
		updateFeeds();
	}
});

function updateFeeds() {
   	new Request( {
   		method : 'get',
   		url : '/parser_test.php'+location.search,
   		onRequest : function() {
   			$('parser-update').className = 'visible';
   			$('parser-update').innerHTML = 'Updating feeds..';
   		},
    	onComplete : function(response) {
   			$('parser-update').innerHTML = response;
   		}
   	}).send();
}